package com.zeroxml.cms.service.impl;

import com.zeroxml.cms.service.IArticleService;
import com.zeroxml.cms.dao.IArticleDAO;
import com.zeroxml.cms.bo.Article;
import com.wyvoid.core.persistent.hibernate.HibernatePage;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * User: cjp
 * Date: 2007-9-9
 * Time: 19:45:18
 */
@Transactional
public class ArticleService implements IArticleService {
    private IArticleDAO articleDAO;

    public void setArticleDAO(IArticleDAO articleDAO) {
        this.articleDAO = articleDAO;
    }

    public Article getArticle(long id) {
        return articleDAO.getById(id);
    }

    public void updateArticle(Article article) {
        articleDAO.update(article);
    }

    public void createArticle(Article article) {
        articleDAO.create(article);
    }

    public void deleteArticle(long id) {
        articleDAO.deleteById(id);
    }

    public HibernatePage<Article> getShowOnIndexArticles(int curPage, int pageSize) {
        return articleDAO.getShowOnIndexArticles(curPage,pageSize);
    }

    public HibernatePage<Article> findArticles(long catalogId, String articleName, int curPage, int pageSize) {
        return articleDAO.findArticles(catalogId,articleName,curPage,pageSize);
    }

    public HibernatePage<Article> getArticles(long tagId,int curPage,int pageSize) {
        return articleDAO.getArticles(tagId,curPage,pageSize);
    }

    public List<Article> getLatestArticles(int articleSize) {
        return articleDAO.getLatestArticles(articleSize);
    }

    public List<Article> getRecommedArticles(long catalogId) {
        return articleDAO.getRecommedArticles(catalogId);
    }
}
